package com.tl.web05.controller; /**
 *
 */

import com.alibaba.fastjson.JSONObject;
import com.tl.web05.config.Config;
import com.tl.web05.constant.ResponseResult;
import com.tl.web05.dao.UserDao;
import com.tl.web05.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "FindAllUserServlet", urlPatterns = "/ajax_findAll")
public class FindAllUserServlet extends HttpServlet {
    private UserService userService = new UserService(new UserDao());

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType(Config.RESP_JSON_CONTENT_TYPE);

        ResponseResult allUser = userService.findAllUser();

        response.getWriter().print(JSONObject.toJSONString(allUser));
        
    }
}
